package cn.melonlib.authentication.comp.service;

import cn.melonlib.cores.identification.comp.messenger.OrganizationManager;
import cn.melonlib.cores.identification.model.entity.Organization;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@ConditionalOnProperty(value = "security.auth.tenant",havingValue = "cookie",matchIfMissing = false)
public class CookieOrganizationManager implements OrganizationManager<String> {

    @Resource
    @Lazy
    private CookieAuthMessenger cookieAuthMessenger;
    @Override
    public Organization<String> getOrganization() {
        return cookieAuthMessenger.getProfile().getTenantView();
    }

    @Override
    public String getCode() {
        return getCode();
    }
}
